package com.acwing.partition8;

import java.io.*;
import java.util.Arrays;
import java.util.Comparator;

/**
 * @author `RKC`
 * @date 2022/2/26 21:38
 */
public class AC798差分矩阵 {

    private static final int N = 1010;
    private static int[][] a = new int[N][N], s = new int[N][N];
    private static int n, m, q;

    private static final BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    private static final BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(System.out));

    public static void main(String[] args) throws IOException {
        String[] ss = reader.readLine().split(" ");
        n = Integer.parseInt(ss[0]);
        m = Integer.parseInt(ss[1]);
        q = Integer.parseInt(ss[2]);
        //读入数据计算差分矩阵
        for (int i = 1; i <= n; i++) {
            ss = reader.readLine().split(" ");
            for (int j = 1; j <= m; j++) {
                a[i][j] = Integer.parseInt(ss[j - 1]);
                s[i - 1][j - 1] = a[i][j] - a[i - 1][j] - a[i][j - 1] + a[i - 1][j - 1];
            }
        }
        while (q-- > 0) {
            ss = reader.readLine().split(" ");
            int x1 = Integer.parseInt(ss[0]), y1 = Integer.parseInt(ss[1]), x2 = Integer.parseInt(ss[2]), y2 = Integer.parseInt(ss[3]);
            int c = Integer.parseInt(ss[4]);
            s[x1 - 1][y1 - 1] += c;
            s[x1 - 1][y2] -= c;
            s[x2][y1 - 1] -= c;
            s[x2][y2] += c;
        }
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= m; j++) {
                a[i][j] = a[i - 1][j] + a[i][j - 1] + s[i - 1][j - 1] - a[i - 1][j - 1];
                writer.write(a[i][j] + " ");
            }
            writer.write("\n");
        }
        writer.flush();
    }
}
